package com.atwork.wuhua.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.atwork.wuhua.R;
import com.atwork.wuhua.bean.DataBean;
import com.atwork.wuhua.bean.FieldDetailListBean;
import com.atwork.wuhua.bean.FieldDetialBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class FieldDetialchildAdapter extends BaseQuickAdapter<FieldDetailListBean.DataBeanX.TimeSlotBean.DataBean, BaseViewHolder> {
    private Context context;

    public FieldDetialchildAdapter(Context context, int layoutResId, @Nullable List<FieldDetailListBean.DataBeanX.TimeSlotBean.DataBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, FieldDetailListBean.DataBeanX.TimeSlotBean.DataBean item) {
        helper.addOnClickListener(R.id.tv_name);
        if (item.isIs_reserved()) {
            helper.setText(R.id.tv_name, "约满");
            ((TextView) helper.getView(R.id.tv_name)).setSelected(false);
            ((TextView) helper.getView(R.id.tv_name)).setTextColor(context.getResources().getColor(R.color.A666));

        } else {

            if (!item.isCan_select()){
                helper.setText(R.id.tv_name, "约满");
                ((TextView) helper.getView(R.id.tv_name)).setSelected(false);
                ((TextView) helper.getView(R.id.tv_name)).setTextColor(context.getResources().getColor(R.color.A666));
            }else {
                helper.setText(R.id.tv_name, "预约");
                ((TextView) helper.getView(R.id.tv_name)).setSelected(true);
                ((TextView) helper.getView(R.id.tv_name)).setTextColor(context.getResources().getColor(R.color.white));
            }



        }

        if (item.isCheck()) {
            helper.getView(R.id.img_s).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.img_s).setVisibility(View.GONE);
        }
    }
}
